﻿{% extends "base/index.html" %}

{% block css %}

{% endblock %}


{% block center %}

    <!--用户信息-->
    <div class="panel panel-default center-top" style="min-width:auto;">
        <div class="panel-heading">
            <div class="row" style="padding-top:0px;padding-left:10px;">
                <div class="col-sm-3">
                    <span class="btn" style="color: green">用户日志</span>
                </div>
                <div class="col-sm-6">
                </div>
                <div class="col-sm-3">
                    <div class="input-group">
                        <input type="text" class="form-control" placeholder="Search for key ..." id="search-key">
                        <span class="input-group-btn">
                            <button class="btn btn-primary" type="button" id="sub-search">搜索</button>
                        </span>
                    </div><!-- /input-group -->
                </div>
            </div>
        </div>

        <div class="panel-body" id="site-info">
            <div style="margin-bottom: 10px;">
                <div class="col-sm-12" id="userlog-log">
                    <table class="table table-hover">
                        <thead>
                        <tr style="background-color: #f5f5f5; text-align:center">
                            <th>ID</th>
                            <th>用户</th>
                            <th>访问操作</th>
                            <th>时间</th>
                            <th>状态</th>
                            <th>请求内容</th>
                        </tr>
                        </thead>
                        <tbody id="uplog_table">
                        {% for i in data_list %}
                            <tr name="tbody">
                                <td>{{ i.id }}</td>
                                <td>{{ i.user }}</td>
                                <td>{{ i.menu }}---{{ i.action }}</td>
                                <td>{{ i.create_time|date:"Y-m-d H:m:i" }}</td>
                                <td>
                                    {% if i.status == "SUCCESS" %}
                                        <span class="label label-success">
                                    {% elif i.status == "DENY" %}
                                        <span class="label label-warning">
                                    {% else %}
                                        <span class="label label-danger">
                                    {% endif %}
                                    {{ i.status }}
                                    </span>
                                </td>
                                <td>
                                    <div style="max-width:120px;white-space:nowrap;overflow:hidden;text-overflow: ellipsis;" name="up-connect">{{ i.req_data }}</div>
                                </td>
                            </tr>
                        {% endfor %}
                        </tbody>
                    </table>

                    <div class="text-right" style="margin-top:-30px;padding-right:9%">
                        <ul class="pagination" id="pager">
                            <li class="previous"><a href="/log/user/1/">首页</a></li>
                            {#上一页按钮开始#}
                            {# 如果当前页有上一页#}
                            {% if data_list.has_previous %}
                                {#  当前页的上一页按钮正常使用#}
                                <li class="previous"><a href="/log/user/{{ data_list.previous_page_number }}/">上一页</a>
                                </li>
                            {% else %}
                                {# 当前页的不存在上一页时,上一页的按钮不可用#}
                                <li class="previous disabled"><a href="javascript:;">上一页</a></li>
                            {% endif %}
                            {#上一页按钮结束#}
                            {# 页码开始#}
                            {% for num in page_list %}
                                {% if num == "..." %}
                                    <li class="item"><a href="javascript:;">{{ num }}</a></li>
                                {% else %}
                                    {% if num == currentPage %}
                                        <li class="item active"><a href="/log/user/{{ num }}/">{{ num }}</a></li>
                                    {% else %}
                                        <li class="item"><a href="/log/user/{{ num }}/">{{ num }}</a></li>
                                    {% endif %}
                                {% endif %}
                            {% endfor %}

                            {#页码结束#}
                            {# 下一页按钮开始#}
                            {% if data_list.has_next %}
                                <li class="next"><a href="/log/user/{{ data_list.next_page_number }}/">下一页</a></li>
                            {% else %}
                                <li class="next disabled"><a href="javascript:;">下一页</a></li>
                            {% endif %}
                            <li class="previous"><a href="/log/user/{{ page_nums }}/">尾页</a></li>
                            {# 下一页按钮结束#}
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>


{% endblock %}


<!-- Modal -->
{% block modal %}



{% endblock %}

{% block js %}
    <script type="text/javascript">

        $("div[name='up-connect']").mouseover(function () {
            var up_content = $(this).html();
            var content_list = up_content.split('##');
            str_html = '';
            for (i = 0; i < content_list.length; i++) {
                str_html += "<p>" + content_list[i] + "</p>";

            }
            $(this).popover({
                trigger: "hover",
                placement: "right",
                html: true,
                content: str_html,
            });
            $(this).popover('show');
        });

        $("#sub-search").click(function () {
            var search_key = $("#search-key").val();
            $.post('/log/ulgsearch/', {'search_key': search_key}, function (data) {
                if (data == "False") {
                    spop({
                        template: "无权限操作",
                        style: 'warning',
                        autoclose: 5000
                    });
                } else {
                    $("#userlog-log").empty();
                    $("#userlog-log").append(data);
                }
            });
        });


    </script>
{% endblock %}


